/**
 * 栈: 先进后出
 * 队列: 先进先出
 */


// 封装一个栈
class Stack {
  constructor(data) {
    this.data = data;
  }
  
  push(data) {
    this.data.push(data);
  }
  
  pop() {
    return this.data.pop();
  }
}

let stack = new Stack([1, 2, 3]);
stack.push(4);
console.log("▶『stack』", stack);
stack.pop();
console.log("▶『stack』", stack);


// 封装一个队列
class Queue {
  constructor(data) {
    this.data = data;
  }
  
  push(data) {
    this.data.push(data);
  }
  
  shift() {
    return this.data.shift();
  }
}

let queue = new Queue([1, 2, 3]);
queue.push(4);
console.log("▶『queue』", queue);
queue.shift();
console.log("▶『queue』", queue);
